<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生管理页面</title>
    <%@include file="template/resources.jsp" %>
    <link rel="stylesheet" href="<c:url value="/css/index.css"/> ">
</head>
<body id="dataStu">
<%@include file="template/notice.jsp" %>
<div class="container web-font">
    <div class="title">
        <h3 class="web-font">学生基本信息列表</h3>
        <c:if test="${ sessionScope.name != null }">
            <div class="login-user" id="login-user">
                <span>${ sessionScope.name }</span>
                <div class="login-user-option" id="user-option">
                    <li><a href="javascript:;" id="open-upload"><i class="fa fa-upload"></i> 数据导入</a></li>
                    <li><a target="_blank" href="<c:url value="/file?action=download" />"><i
                            class="fa fa-download"></i> 数据导出</a></li>
                    <li><a href="<c:url value="/admin?action=signOut"/> "><i class="fa fa-sign-out"></i> 退出登录</a></li>
                </div>
            </div>
        </c:if>
    </div>
    <div class="headers">
        <button class="me-add-user" id="open-add">添加</button>
        <form action="<c:url value="/student?action=search" />" method="post">
            <input type="text" value="${ requestScope.key }" required="required" placeholder="输入学生姓名进行查询"
                   name="key">
            <div class="underline"></div>
            <i class="fa fa-search"></i>
            <input type="submit" value="查询"/>
        </form>
    </div>
    <c:if test="${ requestScope.key != null }">
        <nav>
            <a href="<c:url value="/" /> "><i class="fa fa-arrow-left"></i> 返回</a>
        </nav>
    </c:if>
    <table>
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>年龄</th>
            <th>身高</th>
            <th>体重</th>
            <th>爱好</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${ requestScope.pageStudent.studentList }" var="student">
            <tr>
                <td>${ student.stuId }</td>
                <td>
                    <input type="text" value="${ student.name }" disabled="disabled"/>
                    <i class="fa fa-edit"></i>
                </td>
                <td>
                    <input type="text" value="${ student.sex }" disabled="disabled"/>
                    <i class="fa fa-edit"></i>
                </td>
                <td>
                    <input type="text" value="${ student.age }" disabled="disabled"/>
                    <i class="fa fa-edit"></i>
                </td>
                <td>
                    <input type="text" value="${ student.height }" disabled="disabled"/>
                    <i class="fa fa-edit"></i>
                </td>
                <td>
                    <input type="text" value="${ student.weight }" disabled="disabled"/>
                    <i class="fa fa-edit"></i>
                </td>
                <td>
                    <input type="text" value="${ student.hobby }" disabled="disabled"/>
                    <i class="fa fa-edit"></i>
                </td>
                <td>
                    <button data-current="${ requestScope.pageStudent.currentPage }"
                            data-content="<%=request.getContextPath()%>"
                            data-id="${ student.id }"
                            data-code="${ student.stuId }" class="me-upload">提交
                    </button>
                    <button data-allstu="${ requestScope.pageStudent.totalStudent }"
                            data-id="${ student.id }"
                            data-allpage="${ requestScope.pageStudent.totalPage }"
                            data-current="${ requestScope.pageStudent.currentPage }"
                            data-content="<%=request.getContextPath()%>"
                            class="me-delete">删除
                    </button>
                </td>
            </tr>
        </c:forEach>
    </table>
    <c:if test="${ requestScope.pageStudent.studentList.size() == 0 }">
        <div class="me-empty">
            <img src="<c:url value="/img/empty.png"/> "/>
        </div>
    </c:if>
    <div class="pagination">
        <c:if test="${ requestScope.pageStudent.currentPage > 1 }">
            <c:choose>
                <c:when test="${ requestScope.key != null }">
                    <a href="<c:url value="/page?action=pageSearch&key=${ requestScope.key }&currentPage=${ requestScope.pageStudent.currentPage-1 }"/> ">上一页</a>
                </c:when>
                <c:otherwise>
                    <a href="<c:url value="/page?action=pageAll&currentPage=${ requestScope.pageStudent.currentPage-1 }&info=ok"/>">上一页</a>
                </c:otherwise>
            </c:choose>
        </c:if>
        <span>共${ requestScope.pageStudent.totalStudent }条数据, 当前${ requestScope.pageStudent.currentPage }/${ requestScope.pageStudent.totalPage }</span>
        <c:if test="${ requestScope.pageStudent.currentPage < requestScope.pageStudent.totalPage }">
            <c:choose>
                <c:when test="${ requestScope.key != null }">
                    <a href="<c:url value="/page?action=pageSearch&key=${ requestScope.key }&currentPage=${ requestScope.pageStudent.currentPage+1 }"/> ">下一页</a>
                </c:when>
                <c:otherwise>
                    <a href="<c:url value="/page?action=pageAll&currentPage=${ requestScope.pageStudent.currentPage+1 }&info=ok"/>">下一页</a>
                </c:otherwise>
            </c:choose>
        </c:if>
    </div>
</div>

<div class="model-background">
    <%@include file="template/add/index.jsp" %>
    <%@include file="template/upload/index.jsp" %>
</div>


<script type="text/javascript" src="<c:url value="/js/index.js"/> "></script>
</body>
</html>
